What is @changesets/read?
@changesets/read is an npm package that provides utilities for reading and parsing changeset files. Changesets are used to manage versioning and changelogs in a project, and this package helps in extracting and interpreting the information contained in those changesets.
What are @changesets/read's main functionalities?
Reading Changesets
This feature allows you to read a changeset file from a specified path. The `readChangeset` function reads the changeset file and returns its contents, which can then be used for further processing.
const { readChangeset } = require('@changesets/read');
const path = require('path');
async function readExample() {
const changesetPath = path.join(__dirname, '.changeset', 'example-changeset.md');
const changeset = await readChangeset(changesetPath);
console.log(changeset);
}
readExample();
Reading All Changesets
This feature allows you to read all changeset files from a specified directory. The `readChangesets` function reads all changeset files in the directory and returns their contents as an array.
const { readChangesets } = require('@changesets/read');
const path = require('path');
async function readAllExample() {
const changesetsDir = path.join(__dirname, '.changeset');
const changesets = await readChangesets(changesetsDir);
console.log(changesets);
}
readAllExample();
Other packages similar to @changesets/read
conventional-changelog
The `conventional-changelog` package is used to generate changelogs based on conventional commits. It reads commit messages, parses them according to conventional commit guidelines, and generates a changelog. Unlike @changesets/read, which focuses on reading changeset files, `conventional-changelog` works directly with commit messages.
standard-version
The `standard-version` package automates versioning and changelog generation based on conventional commit messages. It reads commit messages, updates the version number, and generates a changelog. While @changesets/read is focused on reading changeset files, `standard-version` provides a more comprehensive solution for versioning and changelog management.
lerna
Lerna is a tool for managing JavaScript projects with multiple packages. It includes features for versioning, publishing, and managing dependencies between packages. Lerna can also generate changelogs, but its primary focus is on monorepo management. In contrast, @changesets/read is specifically designed for reading changeset files.
@changesets/read
Read in all changesets from a repository.
import read from "@changesets/read";
let changesets = await getChangesets(cwd);
This returns an array of formatted changesets.